# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union, List
from fastapi import Query
from pydantic import BaseModel, Field


class KnowArchiveSearchIn(BaseModel):
    """ 文档搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    know_id: int = Query(default=0, ge=0, description="知识库ID")
    keyword: Union[str, None] = Query(default=None, description="关键词")


class KnowArchiveDetailIn(BaseModel):
    """ 文档详情参数 """
    id: int = Query(..., ge=1, description="文档ID")


class KnowArchiveDeleteIn(BaseModel):
    """ 文档删除参数 """
    ids: List[int] = Field(..., description="文档ID")

    class Config:
        json_schema_extra = {
            "example": {
                "ids": [1, 2, 8]
            }
        }


"""--------------- Separator ---------------"""


class KnowArchiveListVo(BaseModel):
    """ 文档列表VO """
    id: int = Field(description="文件ID")
    code: str = Field(description="文件编号")
    name: str = Field(description="文件名称")
    know: str = Field(description="知识库名")
    train_mode: str = Field(description="训练模式: [chunk=直接分段, qa=问答拆分]")
    train_total: int = Field(description="数据总量")
    train_waits: int = Field(description="等待学习")
    train_yes: int = Field(description="学习成功")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "code": "70efdf2ec9b086079795c442636b55fb",
                "name": "test.txt",
                "know": "test.txt",
                "train_mode": "chunk",
                "train_total": 1,
                "train_waits": 0,
                "train_yes": 0,
                "is_disable": 0,
                "create_time": "2024-09-28 17:16:48",
                "update_time": "2024-09-28 17:16:48"
            }
        }


class KnowArchiveDetailVo(BaseModel):
    """ 文档详情VO """
    code: str = Field(description="文档编号")
    name: str = Field(description="文档名称")
    size: int = Field(description="文档大小")
    train_mode: str = Field(description="训练模式: [chunk=直接分段, qa=问答拆分]")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")

    class Config:
        json_schema_extra = {
            "example": {
                "code": "c7f0f895fb98ab9159f51fd0297e236d",
                "name": "test.docx",
                "size": 100,
                "train_mode": "chunk",
                "is_disable": 0,
                "create_time": "2024-08-27 14:40:21",
                "update_time": "2024-08-27 14:40:21"
            }
        }
